package com.sxm.yiwei.activitis;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.icu.text.NumberFormat;
import android.media.MediaCodec;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.sxm.yiwei.MainActivity;
import com.sxm.yiwei.R;
import com.sxm.yiwei.tools.ErrType;
import com.sxm.yiwei.utils.InternetAddressUtis;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HopeSengActivity extends BaseActivity implements View.OnClickListener{

    private Button buttom1,buttom2,buttom3,buttom4,buttom5;
    private Button sendagain;
    private Button sendbegain;
    private ImageView sendback;
    private EditText contentno;
    private EditText contentmoney;
    private EditText toline;
    private String contentNum;
    private String money;
    private String interval;
    private int num;
    private int anInt;
    private String a = "1";
    private RelativeLayout custom;
    private double mon;
    private double Dmon;
    private TextView tMoney;
    private RelativeLayout one;
    private RelativeLayout two;
    private Parcelable photo;
    private String text;
    private TextView hopeText;
    private ImageView sendimg;
    private TextView sendtext;
    private String type;
    private SharedPreferences sharedPreferences;
    private String appId;
    private String userId;
    private String token;
    private String urlimg;
    private final int requestCode = 1000;
    private String grade1;
    private String issex1;
    private String isstatus1;
    private String dank1;
    private Bundle extras;
    private AlertDialog dialog;
    private String longitude;
    private String latitude;
    private RelativeLayout hopedingzhi1;
    private RelativeLayout hopedingzhi2;
    private RelativeLayout hopedingzhi3;
    private LinearLayout hcontentbac;
    private PopupWindow gradePop;
    private ImageView hgradeimg;
    private int hgno = 1001;
    private int hsno = 1001;
    private int hbno = 1001;
    private ImageView sellimg;
    private TextView hopebaot;
    private EditText inmoney;
    private ImageView inmoneybt;
    private ImageView indistancebt;
    private ImageView contentnobt;
    private EditText indistance;
    private ImageView backmain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hope_seng);
        sharedPreferences = getSharedPreferences("userlogin", Context.MODE_PRIVATE);
        appId = sharedPreferences.getString("appid","");
        userId = sharedPreferences.getString("userId", "");
        token = sharedPreferences.getString("token", "");
        longitude = sharedPreferences.getString("longitude", "");
        latitude = sharedPreferences.getString("latitude", "");

        inithopeView();
        type= "手气红包";
        Intent intent = getIntent();
        photo = intent.getParcelableExtra("photo");
        text = intent.getStringExtra("text");
        urlimg = intent.getStringExtra("imgurl");

        // 设置显示图片
        sendimg.setImageBitmap((Bitmap) photo);
        sendtext.setText(text);

    }

    private void inithopeView() {
        hopedingzhi1 = (RelativeLayout) findViewById(R.id.hope_dingzhi1);
        hopedingzhi2 = (RelativeLayout) findViewById(R.id.hope_dingzhi2);
        hopedingzhi3 = (RelativeLayout) findViewById(R.id.hope_dingzhi3);
        inmoney = (EditText) findViewById(R.id.hopesend_inmoney);
        inmoneybt = (ImageView) findViewById(R.id.hopesend_inmoneybt);
        indistancebt = (ImageView) findViewById(R.id.hope_toinputbt);
        indistance = (EditText) findViewById(R.id.hope_toinput);
        contentno = (EditText) findViewById(R.id.hope_contentno);// 红包分数
        contentnobt = (ImageView) findViewById(R.id.hope_contentnobt);
        backmain = (ImageView) findViewById(R.id.hopesend_backmain);
        backmain.setOnClickListener(this);
        inmoney.setFocusable(false);
        inmoney.setFocusableInTouchMode(false);
        contentno.setFocusable(false);
        contentno.setFocusableInTouchMode(false);
        indistance.setFocusable(false);
        indistance.setFocusableInTouchMode(false);


        hgradeimg = (ImageView) findViewById(R.id.hope_gradeimg);
        hopebaot = (TextView) findViewById(R.id.hope_selectbao);
        buttom1 = (Button) findViewById(R.id.hope_button1);
        buttom2 = (Button) findViewById(R.id.hope_button2);
        buttom3 = (Button) findViewById(R.id.hope_button3);
        buttom4 = (Button) findViewById(R.id.hope_button4);
        buttom5 = (Button) findViewById(R.id.hope_button5);
        sendbegain = (Button) findViewById(R.id.hsend_begain);
        sendback = (ImageView) findViewById(R.id.hope_send_back);
        custom = (RelativeLayout) findViewById(R.id.hope_custom);
       // tMoney = (TextView) findViewById(R.id.hope_textmoney);
        one = (RelativeLayout) findViewById(R.id.hope_one);
        sellimg = (ImageView) findViewById(R.id.hope_sellimg);
        two = (RelativeLayout) findViewById(R.id.hope_two);
        sendimg = (ImageView) findViewById(R.id.hopesend_img);


        sendtext = (TextView) findViewById(R.id.hopesend_text);
        hcontentbac = (LinearLayout) findViewById(R.id.hope_contentbac);
        hcontentbac.setAlpha(0.6f);

      //  contentmoney = (EditText) findViewById(R.id.hope_contentmoney);//数钱
      //  toline = (EditText) findViewById(R.id.hope_toinput);//距离
        contentno.setText("20");
       // contentmoney.setText("1");
     //   toline.setText("5421");


        // 给按钮添加点击数件
        buttom1.setOnClickListener(this);
        buttom2.setOnClickListener(this);
        buttom3.setOnClickListener(this);
        buttom4.setOnClickListener(this);
        buttom5.setOnClickListener(this);

        buttom1.setSelected(true);
        sendbegain.setOnClickListener(this);
        sendback.setOnClickListener(this);
        custom.setOnClickListener(this);
        hopedingzhi1.setOnClickListener(this);
        hopedingzhi2.setOnClickListener(this);
        hopedingzhi3.setOnClickListener(this);
        indistancebt.setOnClickListener(this);
        contentnobt.setOnClickListener(this);
        inmoneybt.setOnClickListener(this);
        // 获取输入内容
        //getHopeInPut();

    }
    // 获取输入内容
    private void getHopeInPut() {
        // 红包数量
        contentNum = String.valueOf(contentno.getText());

        //红包总钱数
        money = String.valueOf(contentmoney.getText());

        //距离
        interval = String.valueOf(toline.getText());


        // 装成int
        num = Integer.parseInt(contentNum);

       // int i = Integer.parseInt(money);
        Dmon = Double.valueOf(money).doubleValue();


        anInt = Integer.parseInt(interval);
        tMoney.setText(Dmon+"");
            //  监听editext 的内容变化 并且显示在textview中
        contentmoney.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                Pattern pattern = Pattern.compile("^[0-9]+(.[0-9]{2})?$");
                Matcher isNum = pattern.matcher(contentmoney.getText());
                if( !isNum.matches() ){
                    //Toast.makeText(HopeSengActivity.this, "请您输入正确的数字", Toast.LENGTH_SHORT).show();
                }else{
                    //tMoney.setText(contentmoney.getText());
                }

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode==RESULT_OK){
            extras = data.getExtras();
            grade1 = extras.getString("grade");
            issex1 = extras.getString("issex");
            isstatus1 = extras.getString("isstatus");
            dank1 = extras.getString("dank");
            // 定制
            a ="5";
            type = "定制红包";
            one.setBackgroundResource(R.color.colorAb);
            two.setBackgroundResource(R.color.colorAb);
            contentmoney.setEnabled(true);
            contentno.setEnabled(true);
            toline.setEnabled(true);
            custom.setVisibility(View.VISIBLE);
            buttom1.setSelected(false);
            buttom2.setSelected(false);
            buttom3.setSelected(false);
            buttom4.setSelected(false);
            buttom5.setSelected(true);

        }

    }

    @Override
    public void onClick(View v) {
       // getHopeInPut();

        switch (v.getId()){
            case R.id.hopesend_backmain:
                startActivity(new Intent(HopeSengActivity.this, MainActivity.class));
                AppManager.getAppManager().finishAllActivity();
                break;
            case R.id.hope_toinputbt:
                indistance.setFocusable(true);
                indistance.setFocusableInTouchMode(true);
                break;
            case R.id.hopesend_inmoneybt:
                inmoney.setFocusable(true);
                inmoney.setFocusableInTouchMode(true);
                break;
            case R.id.hope_contentnobt:
                contentno.setFocusable(true);
                contentno.setFocusableInTouchMode(true);
                break;
            case R.id.hope_dingzhi1:

                showGradeWindow(v);
                break;
            case R.id.hope_dingzhi2:

                showSellWindow(v);
                break;
            case R.id.hope_dingzhi3:
                showBaoWindow(v);
                break;

            case R.id.hope_send_back:
                finish();
                break;
            case R.id.hope_button1:
                // 手气
                type = "手气红包";
                a = "1";
               /* one.setBackgroundResource(R.color.colorAb);
                two.setBackgroundResource(R.color.colorAb);
                contentmoney.setEnabled(true);
                contentno.setEnabled(true);
                toline.setEnabled(true);*/
                custom.setVisibility(View.GONE);
                buttom1.setSelected(true);
                buttom2.setSelected(false);
                buttom3.setSelected(false);
                buttom4.setSelected(false);
                buttom5.setSelected(false);

                break;
            case R.id.hope_button2:
                // 均分
                a= "2";
                type = "均分红包";
                /*one.setBackgroundResource(R.color.colorAb);
                two.setBackgroundResource(R.color.colorAb);
                contentmoney.setEnabled(true);
                contentno.setEnabled(true);
                toline.setEnabled(true);*/
                custom.setVisibility(View.GONE);
                buttom1.setSelected(false);
                buttom2.setSelected(true);
                buttom3.setSelected(false);
                buttom4.setSelected(false);
                buttom5.setSelected(false);
                break;
            case R.id.hope_button3:
                // 一心
                a ="3";
                type = "一心红包";
                /*one.setBackgroundResource(R.color.colorAB);
                two.setBackgroundResource(R.color.colorAB);
                Dmon=10.00;
                contentmoney.setEnabled(false);
                contentno.setEnabled(false);
                toline.setEnabled(false);
                contentmoney.setText("10.00");
                contentno.setText("10");
                toline.setText("5421");
                tMoney.setText(Dmon+"");*/
                custom.setVisibility(View.GONE);
                buttom1.setSelected(false);
                buttom2.setSelected(false);
                buttom3.setSelected(true);
                buttom4.setSelected(false);
                buttom5.setSelected(false);
                break;
            case R.id.hope_button4:
                // 二意
                a="4";
                type = "二意红包";
               /* Dmon=100.00;
                one.setBackgroundResource(R.color.colorAB);
                two.setBackgroundResource(R.color.colorAB);
                contentmoney.setEnabled(false);
                contentno.setEnabled(false);
                toline.setEnabled(false);
                contentmoney.setText("100.00");
                contentno.setText("10");
                toline.setText("5421");
                tMoney.setText(Dmon+"");
                tMoney.setText(Dmon+"");*/
                custom.setVisibility(View.GONE);
                buttom1.setSelected(false);
                buttom2.setSelected(false);
                buttom3.setSelected(false);
                buttom4.setSelected(true);
                buttom5.setSelected(false);
                break;
            case R.id.hope_button5:
                // 定制
                a ="5";
                type = "定制红包";
               /* contentmoney.setText("100.00");
                contentno.setText("100");
                one.setBackgroundResource(R.color.colorAb);
                two.setBackgroundResource(R.color.colorAb);
                contentmoney.setEnabled(true);
                contentno.setEnabled(true);
                toline.setEnabled(true);*/
                custom.setVisibility(View.VISIBLE);
                buttom1.setSelected(false);
                buttom2.setSelected(false);
                buttom3.setSelected(false);
                buttom4.setSelected(false);
                buttom5.setSelected(true);
                break;
            case R.id.hope_custom:
                // 定制红包
                Intent intent = new Intent(HopeSengActivity.this,HopeCustomActivity.class);

                startActivityForResult(intent,requestCode);
                break;
            case R.id.hsend_begain:
                // 此处判断红包类型
                AlertDialog.Builder builder = new AlertDialog.Builder(HopeSengActivity.this,R.style.NoBackGroundDialog);
                View view = LayoutInflater.from(this).inflate(R.layout.progress_dialog, null);
                ProgressBar diapro = (ProgressBar) view.findViewById(R.id.pro_dia);
                builder.setView(view);
                dialog = builder.create();
                dialog.show();
                if (a.equals("1")|a.equals("2")){
                    if (num>=8&Dmon>=1.0){
                        // startActivity(new Intent(HopeSengActivity.this,YiweiPayActivity.class));
                      //  sendHope();
                    }else{
                        Toast.makeText(this, "红包数量不能小于8,总金额不能小于1元", Toast.LENGTH_SHORT).show();
                    }
                }else if (a.equals("3")|a.equals("4")){
                  //  sendHope();
                }else if (a.equals("5")){
                    if (Dmon>=100.00&&num>=100&&num<=Dmon){

                       // sendHope();
                    }else {
                        Toast.makeText(this, "红包金额不能小于100元,份额不能小于100不能大于红包金额", Toast.LENGTH_SHORT).show();
                    }
                }
                break;
        }
    }
        //保证金弹窗
    private void showBaoWindow(View v) {
        View view = getLayoutInflater().inflate(R.layout.hope_pop, null);

        gradePop = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, 400,true);
        gradePop.setBackgroundDrawable(new BitmapDrawable());
        gradePop.setFocusable(true);
        //显示(靠中间)
        gradePop.showAtLocation(findViewById(R.id.hopesend_pop), Gravity.BOTTOM, 0, 0);
        TextView popsure = (TextView) view.findViewById(R.id.pop_sure);
        final TextView popcancel = (TextView) view.findViewById(R.id.pop_cancel);
        TextView title = (TextView) view.findViewById(R.id.pop_title);
        ListView imglist = (ListView) view.findViewById(R.id.hope_img_list);
        title.setText(" ");
        List<Integer>gradeList = new ArrayList();
        for (int i = 0; i < 2; i++) {
            gradeList.add(i);
        }

        PopAdapter adapter = new PopAdapter(HopeSengActivity.this,gradeList,3);
        imglist.setAdapter(adapter);
        popcancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gradePop.dismiss();
            }
        });
        popsure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (hbno){
                    case 0:
                        hopebaot.setText("未缴纳保证金");
                        break;
                    case 1:
                        hopebaot.setText("已缴纳保证金");
                        break;
                    case 1001:
                        hopebaot.setText("");
                        break;
                }

                gradePop.dismiss();
            }
        });
        imglist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                hbno = position;
            }
        });

    }

    // 销售等级弹窗
    private void showSellWindow(View v) {
        View view = getLayoutInflater().inflate(R.layout.hope_pop, null);

        gradePop = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, 500,true);
        gradePop.setBackgroundDrawable(new BitmapDrawable());
        gradePop.setFocusable(true);
        //显示(靠中间)
        gradePop.showAtLocation(findViewById(R.id.hopesend_pop), Gravity.BOTTOM, 0, 0);
        TextView popsure = (TextView) view.findViewById(R.id.pop_sure);
        final TextView popcancel = (TextView) view.findViewById(R.id.pop_cancel);
        TextView title = (TextView) view.findViewById(R.id.pop_title);
        ListView imglist = (ListView) view.findViewById(R.id.hope_img_list);
        title.setText("选择销售等级");
        List<Integer>gradeList = new ArrayList();
        for (int i = 0; i < 4; i++) {
            gradeList.add(i);
        }

        PopAdapter adapter = new PopAdapter(HopeSengActivity.this,gradeList,2);
        imglist.setAdapter(adapter);

        popsure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (hsno){
                    case 1001:
                        sellimg.setImageResource(R.mipmap.xin);
                        break;
                    case 0:
                        sellimg.setImageResource(R.mipmap.xin);
                        break;
                    case 1:
                        sellimg.setImageResource(R.mipmap.zuan);
                        break;
                    case 2:
                        sellimg.setImageResource(R.mipmap.gaun);
                        break;
                    case 3:
                        sellimg.setImageResource(R.mipmap.jinguan);
                        break;
                }
                gradePop.dismiss();
            }
        });
        popcancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gradePop.dismiss();
            }
        });
        imglist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                hsno= position;
            }
        });

    }

    // 等级弹窗
    private void showGradeWindow(View v) {
        View view = getLayoutInflater().inflate(R.layout.hope_pop, null);

        gradePop = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, 500,true);
        gradePop.setBackgroundDrawable(new BitmapDrawable());
        gradePop.setFocusable(true);
        //显示(靠中间)
        gradePop.showAtLocation(findViewById(R.id.hopesend_pop), Gravity.BOTTOM, 0, 0);
        TextView popsure = (TextView) view.findViewById(R.id.pop_sure);
        final TextView popcancel = (TextView) view.findViewById(R.id.pop_cancel);
        TextView title = (TextView) view.findViewById(R.id.pop_title);
        ListView imglist = (ListView) view.findViewById(R.id.hope_img_list);
        title.setText("选择等级");
        List<Integer>gradeList = new ArrayList();
        for (int i = 0; i < 10; i++) {
            gradeList.add(i);
        }
        PopAdapter adapter = new PopAdapter(HopeSengActivity.this,gradeList,1);
        imglist.setAdapter(adapter);
        popsure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                switch (hgno){
                    case 1001:
                        hgradeimg.setImageResource(R.mipmap.g10);
                        break;
                    case 0:
                        hgradeimg.setImageResource(R.mipmap.g10);
                        break;
                    case 1:
                        hgradeimg.setImageResource(R.mipmap.g1);
                        break;
                    case 2:
                        hgradeimg.setImageResource(R.mipmap.g2);
                        break;
                    case 3:
                        hgradeimg.setImageResource(R.mipmap.g3);
                        break;
                    case 4:
                        hgradeimg.setImageResource(R.mipmap.g4);
                        break;
                    case 5:
                        hgradeimg.setImageResource(R.mipmap.g5);
                        break;
                    case 6:
                        hgradeimg.setImageResource(R.mipmap.g6);
                        break;
                    case 7:
                        hgradeimg.setImageResource(R.mipmap.g7);
                        break;
                    case 8:
                        hgradeimg.setImageResource(R.mipmap.g8);
                        break;
                    case 9:
                        hgradeimg.setImageResource(R.mipmap.g9);
                        break;
                }
                gradePop.dismiss();
            }
        });
        popcancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gradePop.dismiss();
            }
        });
        imglist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                hgno = position;
            }
        });
    }



    // 提交红包信息
    private void sendHope() {
        RequestParams params = new RequestParams(InternetAddressUtis.Url+InternetAddressUtis.HOPE_SENG);
        params.addHeader("Content-Type","application/json");
        params.addHeader("token",token);
        params.addHeader("appId",appId);
        params.addHeader("userId",userId);
        params.addBodyParameter("wish",text);
        params.addBodyParameter("bonus",new File(urlimg));
        params.addBodyParameter("type",a);
        params.addBodyParameter("range",interval);
        params.addBodyParameter("amount",money);
        params.addBodyParameter("size",contentNum);
        params.addBodyParameter("longitude",longitude);
        params.addBodyParameter("latitude",latitude);
        params.addBodyParameter("userGradeCode",grade1);
        params.addBodyParameter("sellGradeCode",dank1);
        params.addBodyParameter("serviceMargin",isstatus1);
        params.addBodyParameter("sex",issex1);
        params.setMultipart(true);
        x.http().post(params, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {

                com.alibaba.fastjson.JSONObject obj = JSON.parseObject(result);
                String data = obj.getString("data");
                com.alibaba.fastjson.JSONObject obj1 = JSON.parseObject(data);
                String bonusId = obj1.getString("bonusId");
                SharedPreferences.Editor edit = sharedPreferences.edit();
                edit.putString("bonusId",bonusId).commit();
                Intent intent = new Intent(HopeSengActivity.this,YiweiPayActivity.class);
                intent.putExtra("type",type);
                intent.putExtra("number",contentNum);
                intent.putExtra("money",money);
                intent.putExtra("bonusId",bonusId);
                startActivity(intent);


            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                ErrType.errType(HopeSengActivity.this,ex);
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {
                dialog.dismiss();

            }
        });
    }


    class PopAdapter extends BaseAdapter {
        Context context;
        List<Integer> list;
        int type;
        public PopAdapter(Context context, List<Integer> list,int type) {
            this.context=context;
            this.list=list;
            this.type= type;
        }
        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            ViewHolder holder;
            if (convertView==null){
                if (type==3){
                    view = View.inflate(context,R.layout.hope_textitem,null);
                }else {
                    view = View.inflate(context,R.layout.hopepop_imgitem,null);
                }

                holder = new ViewHolder();
                holder.popimg = (ImageView) view.findViewById(R.id.hope_pop_img);
                holder.poptext = (TextView) view.findViewById(R.id.hope_itemtext);
                view.setTag(holder);

            }else {
                view= convertView;
                holder = (ViewHolder) view.getTag();
            }

            if (type==1){
                switch (list.get(position)){
                    case 0:
                        holder.popimg.setImageResource(R.mipmap.g10);
                        break;
                    case 1:
                        holder.popimg.setImageResource(R.mipmap.g1);
                        break;
                    case 2:
                        holder.popimg.setImageResource(R.mipmap.g2);
                        break;
                    case 3:
                        holder.popimg.setImageResource(R.mipmap.g3);
                        break;
                    case 4:
                        holder.popimg.setImageResource(R.mipmap.g4);
                        break;
                    case 5:
                        holder.popimg.setImageResource(R.mipmap.g5);
                        break;
                    case 6:
                        holder.popimg.setImageResource(R.mipmap.g6);
                        break;
                    case 7:
                        holder.popimg.setImageResource(R.mipmap.g7);
                        break;
                    case 8:
                        holder.popimg.setImageResource(R.mipmap.g8);
                        break;
                    case 9:
                        holder.popimg.setImageResource(R.mipmap.g9);
                        break;
                }
            }else if (type==2){
                switch (list.get(position)){
                    case 0:
                        holder.popimg.setImageResource(R.mipmap.xin);
                        break;
                    case 1:
                        holder.popimg.setImageResource(R.mipmap.zuan);
                        break;
                    case 2:
                        holder.popimg.setImageResource(R.mipmap.gaun);
                        break;
                    case 3:
                        holder.popimg.setImageResource(R.mipmap.jinguan);
                        break;
                }
            }else {
                switch (list.get(position)){
                    case 0:
                        holder.poptext.setText("未缴纳保证金");
                        break;
                    case 1:
                        holder.poptext.setText("已缴纳保证金");
                        break;
                }
            }

            return view;
        }

        class ViewHolder{
            ImageView popimg;
            TextView poptext;
        }
    }

}
